############################################################################## # Microwindows rules Makefile # Copyright (c) 2000 Martin Jolicoeur, Greg Haerr # Portions Copyright (c) 2002 by Koninklijke Philips Electronics N.V. # # This makefile should be placed at the top of a project hierarchy # # NOTE: The TOP environment variable should be set to that top directory ############################################################################## ifeq ($(ARCH), DJGPP) SHELL = bash else SHELL = /bin/sh endif # install directories for headers and libraries INSTALL_PREFIX = /usr INSTALL_USER = root INSTALL_GROUP = root INSTALL_GROUP_2 = bin HDRINSTALLDIR = $(INSTALL_PREFIX)/include/microwin LIBINSTALLDIR = $(INSTALL_PREFIX)/lib BININSTALLDIR = $(INSTALL_PREFIX)/bin INSTALL_DIR = install -c -m 755 -o $(INSTALL_USER) -g $(INSTALL_GROUP) -d INSTALL_HDR = install -c -m 644 -o $(INSTALL_USER) -g $(INSTALL_GROUP_2) INSTALL_LIB = install -c -m 644 -o $(INSTALL_USER) -g $(INSTALL_GROUP_2) INSTALL_BIN = install -c -m 755 -o $(INSTALL_USER) -g $(INSTALL_GROUP_2) ############################################################################## # Defines, includes, and core libraries. Controlled by the config file. ############################################################################## # Defines DEFINES += -DMWPIXEL_FORMAT=$(SCREEN_PIXTYPE) # Includes INCLUDEDIRS += -I. -I$(TOP)/include # Libraries required for the 'engine' functionality. MW_CORE_LIBS := # Don't do debug for speed issues DEFINES += -DNDEBUG ifeq ($(VTSWITCH), Y) DEFINES += -DVTSWITCH=1 endif ifeq ($(X11), Y) DEFINES += -DX11=1 ifneq ($(ARCH),CYGWIN) # Cygwin can't use this - the -lX11 needs to be specified # *after* the object files that use it, but this inserts # it at the start. For Cygwin, we will add libX11.a to the # library list instead. LDFLAGS += -L/usr/X11R6/lib -lX11 else MW_CORE_LIBS += /usr/X11R6/lib/libX11.a endif ifeq ($(ARCH),FREEBSD-X86) INCLUDEDIRS += -I/usr/X11R6/include endif ifeq ($(ARCH),CYGWIN) INCLUDEDIRS += -I/usr/X11R6/include endif endif ifeq ($(VGALIB), Y) LDFLAGS += -lvga endif ifeq ($(ARCH),FREEBSD-X86) LDFLAGS += -lvgl endif ifeq ($(HAVE_FILEIO), Y) DEFINES += -DHAVE_FILEIO ifeq ($(HAVE_TIFF_SUPPORT), Y) DEFINES += -DHAVE_TIFF_SUPPORT=1 MW_CORE_LIBS += $(LIBTIFF) LDFLAGS += -lm ifneq ($(INCTIFF),) INCLUDEDIRS += -I$(INCTIFF) endif endif ifeq ($(HAVE_JPEG_SUPPORT), Y) DEFINES += -DHAVE_JPEG_SUPPORT=1 MW_CORE_LIBS += $(LIBJPEG) ifneq ($(INCJPEG),) INCLUDEDIRS += -I$(INCJPEG) endif endif ifeq ($(HAVE_PNG_SUPPORT), Y) DEFINES += -DHAVE_PNG_SUPPORT=1 MW_CORE_LIBS += $(LIBPNG) $(LIBZ) ifneq ($(INCPNG),) INCLUDEDIRS += -I$(INCPNG) endif ifneq ($(ARCH), ECOS) LDFLAGS += -lm endif endif ifeq ($(HAVE_FNT_SUPPORT), Y) DEFINES += -DHAVE_FNT_SUPPORT=1 DEFINES += -DFNT_FONT_DIR="\"$(FNT_FONT_DIR)"\" ifeq ($(HAVE_FNTGZ_SUPPORT), Y) DEFINES += -DHAVE_FNTGZ_SUPPORT=1 MW_CORE_LIBS += $(LIBZ) endif endif ifeq ($(HAVE_T1LIB_SUPPORT), Y) DEFINES += -DHAVE_T1LIB_SUPPORT=1 MW_CORE_LIBS += $(LIBT1LIB) ifneq ($(INCT1LIB),) INCLUDEDIRS += -I$(INCT1LIB) endif LDFLAGS += -lm endif ifeq ($(HAVE_FREETYPE_SUPPORT), Y) DEFINES += -DHAVE_FREETYPE_SUPPORT=1 DEFINES += -DFREETYPE_FONT_DIR=\"$(FREETYPE_FONT_DIR)\" MW_CORE_LIBS += $(LIBFTLIB) ifneq ($(INCFTLIB),) INCLUDEDIRS += -I$(INCFTLIB) endif LDFLAGS += -lm endif ifeq ($(HAVE_FREETYPE_2_SUPPORT), Y) ifeq ($(HAVE_FREETYPE_SUPPORT), Y) $(error Having both FreeType 1 and FreeType 2 support is not allowed.) endif DEFINES += -DHAVE_FREETYPE_2_SUPPORT=1 DEFINES += -DFREETYPE_FONT_DIR=\"$(FREETYPE_FONT_DIR)\" MW_CORE_LIBS += $(LIBFT2LIB) # GCC 3.2 complains if system directories (e.g. /usr/include) are # specified with "-I". For most INCxxx, we simply allow the # value to be set to empty to mean "no -I required". # Since FT2 requires $(INCFT2LIB)/freetype2 to always be # specified, we take a slightly different (and less reliable) # approach and simply skip the well-known system directories. ifneq ($(INCFT2LIB),/usr/include) ifneq ($(INCFT2LIB),/usr/local/include) INCLUDEDIRS += -I$(INCFT2LIB) endif endif INCLUDEDIRS += -I$(INCFT2LIB)/freetype2 endif ifeq ($(HAVE_PCF_SUPPORT), Y) DEFINES += -DHAVE_PCF_SUPPORT=1 DEFINES += -DPCF_FONT_DIR="\"$(PCF_FONT_DIR)"\" ifeq ($(HAVE_PCFGZ_SUPPORT), Y) DEFINES += -DHAVE_PCFGZ_SUPPORT=1 MW_CORE_LIBS += $(LIBZ) endif endif ifeq ($(HAVE_HZK_SUPPORT), Y) DEFINES += -DHAVE_HZK_SUPPORT=1 DEFINES += -DHZK_FONT_DIR="\"$(HZK_FONT_DIR)"\" endif ifeq ($(HAVE_BIG5_SUPPORT), Y) DEFINES += -DHAVE_BIG5_SUPPORT=1 endif ifeq ($(HAVE_GB2312_SUPPORT), Y) DEFINES += -DHAVE_GB2312_SUPPORT=1 endif ifeq ($(HAVE_JISX0213_SUPPORT), Y) DEFINES += -DHAVE_JISX0213_SUPPORT=1 endif ifeq ($(HAVE_KSC5601_SUPPORT), Y) DEFINES += -DHAVE_KSC5601_SUPPORT=1 endif ifeq ($(HAVE_EUCJP_SUPPORT), Y) DEFINES += -DHAVE_EUCJP_SUPPORT=1 DEFINES += -DEUCJP_FONT_DIR=\"$(EUCJP_FONT_DIR)\" endif ifeq ($(HAVE_BMP_SUPPORT), Y) DEFINES += -DHAVE_BMP_SUPPORT=1 endif ifeq ($(HAVE_GIF_SUPPORT), Y) DEFINES += -DHAVE_GIF_SUPPORT=1 endif ifeq ($(HAVE_PNM_SUPPORT), Y) DEFINES += -DHAVE_PNM_SUPPORT=1 endif ifeq ($(HAVE_XPM_SUPPORT), Y) DEFINES += -DHAVE_XPM_SUPPORT=1 endif endif ifeq ($(NOFONTSORCLIPPING), Y) DEFINES += -DNOFONTSORCLIPPING=1 endif ifeq ($(HAVE_SHAREDMEM_SUPPORT), Y) DEFINES += -DHAVE_SHAREDMEM_SUPPORT=1 endif ifeq ($(FRAMEBUFFER), Y) ifeq ($(HAVETEXTMODE), Y) DEFINES += -DHAVETEXTMODE=1 else DEFINES += -DHAVETEXTMODE=0 endif endif ifeq ($(THREADSAFE), Y) DEFINES += -DTHREADSAFE=1 #LDFLAGS += -lpthread endif # Driver-specific stuff ifneq ($(ARCH), ELKS) ifneq ($(ARCH), DJGPP) ifeq ($(EM8400), Y) DEFINES += -I$(EM8400_DIR)/include LDFLAGS += -L$(EM8400_DIR)/lib -lEM8400 endif ifeq ($(FRAMEBUFFER), Y) ifeq ($(FBVGA), Y) DEFINES += -DFBVGA=1 endif ifeq ($(INVERT4BPP), Y) DEFINES += -DINVERT4BPP=1 endif endif # FRAMEBUFER ifeq ($(X11), Y) ifeq ($(USE_EXPOSURE), Y) DEFINES += -DUSE_EXPOSURE endif ifdef SCREEN_HEIGHT DEFINES += -DSCREEN_HEIGHT=$(SCREEN_HEIGHT) endif ifdef SCREEN_WIDTH DEFINES += -DSCREEN_WIDTH=$(SCREEN_WIDTH) endif ifdef SCREEN_DEPTH DEFINES += -DSCREEN_DEPTH=$(SCREEN_DEPTH) endif endif # X11 stuff endif # !DJGPP endif # !ELKS ifeq ($(TPHELIO), Y) DEFINES += -DTPHELIO=1 endif # Nano-X specific stuff ifeq ($(NANOX), Y) ifeq ($(LINK_APP_INTO_SERVER), Y) DEFINES += -DNONETWORK=1 endif endif # NANOX # Microwin-specific stuff ifeq ($(MICROWIN), Y) ifeq ($(ERASEMOVE), Y) DEFINES += -DERASEMOVE=1 endif ifeq ($(UPDATEREGIONS), Y) DEFINES += -DUPDATEREGIONS=1 endif endif ############################################################################## # Extra compiler flags. # # Note: Do not set defines, includes or libraries here! ############################################################################## # Some drivers use outb macro, requires -O optimization ifneq ($(ARCH), LINUX-TCC) ifneq ($(ARCH), DJGPP) ifeq ($(ARCH), ELKS) CFLAGS += -O else ifeq ($(FRAMEBUFFER), Y) ifeq ($(FBVGA), Y) CFLAGS += -O endif endif # FRAMEBUFER ifeq ($(HWVGA), Y) CFLAGS += -O endif endif # !ELKS endif # !DJGPP endif # !LINUX-TCC ifneq ($(ARCH), TRIMEDIA) ifeq ($(SHAREDLIBS), Y) CFLAGS += -fpic endif ifeq ($(OPTIMIZE), Y) OPTFLAGS += -O3 endif ifeq ($(GPROF), Y) OPTFLAGS += -pg LDFLAGS += -pg endif endif ifeq ($(DEBUG), Y) OPTFLAGS += -ggdb DEFINES += -DDEBUG=1 else #OPTFLAGS += -DNDEBUG endif CFLAGS += $(INCLUDEDIRS) HOSTCFLAGS := $(INCLUDEDIRS) CPPFLAGS += $(DEFINES) LDFLAGS += -L$(TOP)/lib ifeq ($(ARCH), TRIMEDIA) ARFLAGS = r else ARFLAGS = rs endif ############################################################################## # Tools ############################################################################## # Default tools (may be overridden by Arch.rules) HOSTCC = gcc COMPILER = gcc CXX_COMPILER = g++ ACHIVER = ar LINKER = ld # Include the rules for arch's # if the user has a specific arch local to their home load it # ifeq ($(HOME)/microwin/Arch.rules,$(wildcard $(HOME)/microwin/Arch.rules)) # include $(HOME)/microwin/Arch.rules # else include $(TOP)/Arch.rules # endif # Tools ... ifdef NOT_DEFINED_EVER CC = $(TOOLSPREFIX)$(COMPILER) CXX = $(TOOLSPREFIX)$(CXX_COMPILER) AR = $(TOOLSPREFIX)$(ACHIVER) LD = $(TOOLSPREFIX)$(LINKER) endif NM = $(TOOLSPREFIX)nm # STRIP = $(TOOLSPREFIX)strip OBJCOPY = $(TOOLSPREFIX)objcopy ifdef NOT_DEFINED_EVER RANLIB = $(TOOLSPREFIX)ranlib endif CP = cp MV = mv ############################################################################## # Libraries. # # Note that libraries required by the engine (and only by the engine) are # already set in MW_CORE_LIBS. ############################################################################## MWINLIBS = \ $(TOP)/lib/libmwin.a \ $(TOP)/lib/libmwinlib.a\ $(TOP)/lib/libmwengine.a \ $(TOP)/lib/libmwdrivers.a \ $(TOP)/lib/libmwfonts.a \ $(TOP)/lib/libmwimages.a \ $(MW_CORE_LIBS) CCMWINLIBS = -lmwin -lmwinlib -lmwengine -lmwdrivers -lmwfonts -lmwin -lmwimages -lm $(MW_CORE_LIBS) ifeq ($(LINK_APP_INTO_SERVER), Y) NANOXCLIENTLIBS += \ $(TOP)/lib/libnano-X.a \ $(TOP)/lib/libmwengine.a \ $(TOP)/lib/libmwdrivers.a \ $(TOP)/lib/libmwfonts.a \ $(MW_CORE_LIBS) CCNANOXCLIENTLIBS += -lnano-X -lmwengine -lmwdrivers -lmwfonts $(MW_CORE_LIBS) else NANOXCLIENTLIBS += $(TOP)/lib/libnano-X.a CCNANOXCLIENTLIBS += -lnano-X endif NANOXSERVERLIBS += \ $(TOP)/lib/libmwengine.a \ $(TOP)/lib/libmwdrivers.a \ $(TOP)/lib/libmwfonts.a \ $(MW_CORE_LIBS) CCNANOXSERVERLIBS += -lmwengine -lmwdrivers -lmwfonts ifeq ($(SHAREDLIBS), Y) CCNANOXSERVERLIBS += $(MW_CORE_LIBS) endif ifeq ($(ARCH), ELKS) CCMWINLIBS = $(MWINLIBS) endif ifeq ($(ARCH), DJGPP) CCMWINLIBS += -lgrx20 NANOXCLIENTLIBS += -lgrx20 endif # I think the ARCH is m68knommu. So the "ifeq ($(ARCH), uClinux)" # may not work. I do rather check if people are compiling for our board: ifeq ($(CONFIG_COBRA5272), y) # Compiling for COBRA5272? CCMWINLIBS = $(MWINLIBS) $(MWINLIBS) $(SYS_LIBS) CCNANOXLIBS = $(NANOXLIBS) $(SYS_LIBS) NANOXSERVERLIBS += $(SYS_LIBS) NANOXCLIENTLIBS += $(SYS_LIBS) CCNANOXSERVERLIBS += $(NANOXSERVERLIBS) $(SYS_LIBS) CCNANOXCLIENTLIBS += $(NANOXCLIENTLIBS) $(SYS_LIBS) else # Not compiling for COBRA5272 (same code as before): ifeq ($(ARCH), uClinux) CCMWINLIBS = $(MWINLIBS) $(MWINLIBS) $(SYS_LIBS) CCNANOXLIBS = $(NANOXLIBS) $(SYS_LIBS) NANOXSERVERLIBS += $(SYS_LIBS) NANOXCLIENTLIBS += $(SYS_LIBS) CCNANOXSERVERLIBS += $(NANOXSERVERLIBS) $(SYS_LIBS) CCNANOXCLIENTLIBS += $(NANOXCLIENTLIBS) $(SYS_LIBS) endif # end for "ifeq ($(ARCH), uClinux)". endif # end for "ifeq ($(CONFIG_COBRA5272), y)" ifeq ($(ARCH), CLEOPATRA) ifeq ($(CONFIG_M5307), y) CLEOLIB = $(ROOTDIR)/vendors/Feith/Cleopatra_src/lib/cleopatra.a else CLEOLIB = $(ROOTDIR)/vendors/Feith/Cleopatra2_src/lib/cleopatra2.a endif CCMWINLIBS = $(MWINLIBS) $(MWINLIBS) $(SYS_LIBS) $(CLEOLIB) CCNANOXLIBS = $(NANOXLIBS) $(SYS_LIBS) $(CLEOLIB) NANOXSERVERLIBS += $(SYS_LIBS) $(CLEOLIB) NANOXCLIENTLIBS += $(SYS_LIBS) $(CLEOLIB) CCNANOXSERVERLIBS += $(NANOXSERVERLIBS) $(SYS_LIBS) CCNANOXCLIENTLIBS += $(NANOXCLIENTLIBS) $(SYS_LIBS) endif ifeq ($(ARCH), FREEBSD-X86) # For forkpty in nxterm. NANOXCLIENTLIBS += -lutil endif ############################################################################## # Build rules ############################################################################## # If you dont want to see every executed command ... ifeq ($(VERBOSE), N) .SILENT: endif .PHONY: default subdirs clean cleandepend cleandepend-notsubdir xconfig makedestdirs # Add any exportable variable here export TOP ARCH CONFIG # # This is the default target # It looks for sub-directories with makefiles in it and tries to execute them # ifeq ($(SHAREDLIBS), Y) default: $(TOP)/bin $(TOP)/lib subdirs $(TOP)/lib/$(LIBNAME) $(TOP)/lib/$(LIBNAMESO) else default: $(TOP)/bin $(TOP)/lib subdirs $(TOP)/lib/$(LIBNAME) endif # 'dirs' can be pre-specified ifeq ($(dirs), ) dirs = $(shell for file in `\ls`; \ do if [ -d $$file -a $$file != "demos" ]; then \ if [ -f $$file/Makefile ]; then echo $$file; fi; fi; done) endif # 'demos' can be pre-specified ifeq ($(demos), ) demos = $(shell for file in `\ls`; \ do if [ -d $$file -a $$file = "demos" ]; then \ if [ -f $$file/Makefile ]; then echo $$file; fi; fi; done) endif # # Subdirectories target # # For each directory DIRNAME in $(dirs), we create a phony target # called "subdir-DIRNAME". To build that target, we recurse into # the directory with "$(MAKE) -C DIRNAME". # .PHONY: subdirs $(dirs:%=subdir-%) subdirs: $(dirs:%=subdir-%) @# $(dirs:%=subdir-%): makedestdirs $(MAKE) -C $(subst subdir-,,$@) makedestdirs: ifeq ($(ARCH), DJGPP) $(shell set CURDIR=$(pwd);) $(shell \ if [ ! -d $(TOP)/bin ]; \ then mkdir $(TOP)/bin; fi;) $(shell \ if [ ! -d $(TOP)/lib ]; \ then mkdir $(TOP)/lib; fi;) endif @# # # If a library name is specified, # a library of that name will be created with objects in that directory # ifneq ($(LIBNAME),) $(TOP)/lib/$(LIBNAME): $(OBJS) $(CXXOBJS) @echo "Creating library $@ ..." $(AR) $(ARFLAGS) $(TOP)/lib/$(LIBNAME) $(OBJS) $(CXXOBJS) $(ASMOBJS) -$(RANLIB) $(TOP)/lib/$(LIBNAME) endif # # If a shared object library name is specified, link this object # ifeq ($(SHAREDLIBS), Y) $(TOP)/lib/$(LIBNAMESO): $(TOP)/lib/$(LIBNAME) @echo "Creating shared library $@ ..." $(LD) -shared -o $@ --whole-archive $^ endif # # Make sure that bin and lib directories exist # $(TOP)/bin $(TOP)/lib: @mkdir -p $@ # # Dependencies target for C files # .depend: $(OBJS:.o=.c) $(CXXOBJS:.o=.cc) @echo "Updating dependencies in $(CURDIR) ..." $(SHELL) -ec '$(HOSTCC) -MM $(CPPFLAGS) $(HOSTCFLAGS) $(OBJS:.o=.c) \ | sed '\''s/\($*\)\.o[ :]*/\1.o \$@ : $$(TOP)\/config /g'\'' > $@; \ [ -s $@ ] || rm -f $@' # # Compilation target for C files # %.o:%.c @echo "Compiling $< ..." $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< # # Compilation target for C++ files # %.o:%.cc @echo "C++ compiling $< ..." $(CXX) -c $(CFLAGS) $(CXXFLAGS) -o $@ $< # # Compilation target for bmp file conversion # %.c:%.bmp $(TOP)/bin/convbmp @echo "Generating $@ from bitmap file ..." $(TOP)/bin/convbmp -o $@ $< # # Compilation target for tool that does bmp file conversion # $(TOP)/bin/convbmp: $(TOP)/mwin/bmp/convbmp.c @echo "Building $@ tool ..." $(HOSTCC) $(HOSTCFLAGS) $< -o $@ # # Compilation target for bdf font file conversion # %.c:%.bdf $(TOP)/bin/convbdf @echo "Generating $@ from font file ..." $(TOP)/bin/convbdf -c -o $@ $< # # Compilation target for tool that does bdf font file conversion # $(TOP)/bin/convbdf: $(TOP)/fonts/convbdf.c @echo "Building $@ tool ..." $(HOSTCC) $(HOSTCFLAGS) $< -o $@ xconfig: ./xconfigure # don't clean lib dir cleanapps: cleandepend-notsubdir @echo "Cleaning directory $(CURDIR) ..." $(RM) core *~ *.bak *.o TAGS $(RM) bin/* $(foreach dir, $(dirs), $(MAKE) -C $(dir) cleanapps;) $(foreach dir, $(demos), $(MAKE) -C $(dir) cleanapps;) clean: cleandepend-notsubdir @echo "Cleaning directory $(CURDIR) ..." $(RM) core *~ *.bak *.o TAGS $(RM) $(TOP)/lib/*.a $(TOP)/lib/*.so $(shell cd $(TOP)/bin && \ for file in `\ls`; do if [ ! -d $$file ]; \ then $(RM) $$file; fi; done; cd $(TOP)) $(foreach dir, $(dirs), $(MAKE) -C $(dir) clean;) $(foreach dir, $(demos), $(MAKE) -C $(dir) clean;) cleandepend-notsubdir: @echo "Cleaning dependencies in $(CURDIR) ..." $(RM) .depend cleandepend: cleandepend-notsubdir $(foreach dir, $(dirs), $(MAKE) -C $(dir) cleandepend;) $(foreach dir, $(demos), $(MAKE) -C $(dir) cleandepend;) install: default $(INSTALL_DIR) $(HDRINSTALLDIR) @echo "Copying hdrs to $(HDRINSTALLDIR)" $(INSTALL_HDR) include/*.h $(HDRINSTALLDIR) @echo "Copying libs to $(LIBINSTALLDIR)" $(INSTALL_DIR) $(LIBINSTALLDIR) $(INSTALL_LIB) lib/*.a $(LIBINSTALLDIR) ifeq ($(SHAREDLIBS), Y) $(INSTALL_LIB) lib/*.so $(LIBINSTALLDIR) endif ifeq ($(NANOX), Y) ifeq ($(LINK_APP_INTO_SERVER), N) @echo "Copying binaries to $(BININSTALLDIR)" $(INSTALL_DIR) $(BININSTALLDIR) $(INSTALL_BIN) bin/nano-X $(BININSTALLDIR) else rm -f $(BININSTALLDIR)/nano-X endif else rm -f $(BININSTALLDIR)/nano-X endif @echo "Installation completed successfully." tags: -rm -f TAGS etags --language=c++ --append \ `find . \( -name '*.h' -o -name '*.cc' \) -print` etags --language=c --append `find . -name \*.[hc] -print` etags --language=asm --append `find . -name \*.[Ss] -print` ############################################################################## # Included dependency files ############################################################################## ifneq ($(MAKECMDGOALS), clean) ifneq ($(MAKECMDGOALS), cleandepend) ifneq ($(MAKECMDGOALS), realclean) ifneq ($(MAKECMDGOALS), xconfig) ifneq ($(OBJS),) -include .depend endif endif endif endif endif