# _ _ _ # /_\ __| (_)_ __ ___ # / _ \/ _` | | ' \/ -_) # /_/ \_\__,_|_|_|_|_\___| # # makefile.osx: # Makefile for the Adime library with Mac OS X. # Should not be used directly! # # Original makefile for Unix by Peter Wang, # modifications for Mac OS X by Stijn Wolters, # thanks to Angelo Mottola for all help and tips. # # See readme.txt for more information about Adime. # # See makefile.all for a list of the available targets. # -------- Define some variables that the primary makefile may use. -------- PLATFORM = MACOSX EXE_SUFFIX = OBJ_SUFFIX = .o LIB_SUFFIX = .a HTML_SUFFIX = .html INFO_SUFFIX = .info TEXI_SUFFIX = .texi _TX_HTML_FLAG = -html _TX_TEXI_FLAG = -texi ifndef OBJ_ROOT_DIR OBJ_ROOT_DIR = obj endif OBJ_PLATFORM_ROOT_DIR = $(OBJ_ROOT_DIR)/macosx ifndef LIB_ROOT_DIR LIB_ROOT_DIR = lib endif LIB_DIR = $(LIB_ROOT_DIR)/macosx HAVE_TEXINFO = 1 HAVE_MAN = 1 FRAMEWORK_DIR = /Library/Frameworks FRAMEWORK_NAME = Adime FRAMEWORK = $(FRAMEWORK_DIR)/$(FRAMEWORK_NAME).framework TEMPLATE_DIR = /Developer/ProjectBuilder\ Extras/Project\ Templates/Application ifeq ($(wildcard $(TEMPLATE_DIR)),) TEMPLATE_DIR = /Library/Application\ Support/Apple/Developer\ Tools/Project\ Templates/Application endif TEMPLATE_NAME = Adime\ Application TEMPLATE = $(TEMPLATE_DIR)/$(TEMPLATE_NAME) ifdef EMBED FRAMEWORK_DESCRIPTION = "embeddable" else FRAMEWORK_DESCRIPTION = "system wide" endif ifdef STATICLINK # link as a static library OBJ_DIR = $(OBJ_PLATFORM_ROOT_DIR)/$(PACKAGE5)_s IMPLIB_BASENAME = lib$(PACKAGE5)_s.a IMPLIB_NAME = $(LIB_DIR)/$(IMPLIB_BASENAME) LIB_NAME = $(IMPLIB_NAME) else # link as a shared object OBJ_DIR = $(OBJ_PLATFORM_ROOT_DIR)/$(PACKAGE5) IMPLIB_BASENAME = lib$(PACKAGE5).dylib IMPLIB_NAME = $(LIB_DIR)/$(IMPLIB_BASENAME) LIB_NAME = $(IMPLIB_NAME) INSTALL_NAME_EMBED = -install_name "`echo "@executable_path/../Frameworks/$(FRAMEWORK_NAME).framework/Versions/$(shared_version)/$(FRAMEWORK_NAME)" | sed 's!//*!/!g'`" endif # -------- Default system paths. ------------ ifndef SYSTEM_DIR SYSTEM_DIR = /usr/local endif SYSTEM_INCLUDE_DIR = $(SYSTEM_DIR)/include SYSTEM_LIB_DIR = $(SYSTEM_DIR)/lib SYSTEM_MAN_DIR = $(SYSTEM_DIR)/man SYSTEM_INFO_DIR = $(SYSTEM_DIR)/info INSTALL_INFO = /sbin/install-info ifdef STATICLINK RUN_RANLIB = ranlib $(SYSTEM_LIB_DIR)/$(IMPLIB_BASENAME) endif # -------- Find Allegro and makedoc. -------- ifndef NEED_ALLEGRO ifdef NEED_MAKEDOC ifeq ($(wildcard $(MAKEDOC_SOURCE)),) NEED_ALLEGRO = 1 endif endif endif ifdef NEED_ALLEGRO ifndef ALLEGRO define BADALLEGRO ERROR: Could not find Allegro! Is your ALLEGRO environment variable set correctly? It should point to the place where Allegro lives, e.g. /home/me/allegro. Run make ALLEGRO=/home/me/allegro (or whatever the location of Allegro is). See also readme.txt endef $(error $(BADALLEGRO)) endif ALLEGRODIR_U = $(subst \,/,$(ALLEGRO)) endif # ifdef NEED_ALLEGRO ifdef NEED_MAKEDOC include misc/makefile.doc endif # -------- Decide what compiler options and libraries to use. -------- ifdef WARNMODE WFLAGS = -Wall -W -Werror # -Wno-unused else WFLAGS = -Wall -Wno-unused endif ifdef STATICLINK_ALLEGRO ALLEGRO_CONFIG_FLAGS = --static else ALLEGRO_CONFIG_FLAGS = --shared endif ifdef DEBUGMODE # debugging build CFLAGS = -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS) -g SFLAGS = -DDEBUGMODE=$(DEBUGMODE) $(WFLAGS) LFLAGS += -g LIB_FLAGS = `allegro-config --libs debug $(ALLEGRO_CONFIG_FLAGS)` else ifdef PROFILEMODE # profiling build CFLAGS = $(WFLAGS) $(OFLAGS) -pg SFLAGS = $(WFLAGS) LFLAGS += -pg LIB_FLAGS = `allegro-config --libs profile $(ALLEGRO_CONFIG_FLAGS)` else # optimised build CFLAGS = $(WFLAGS) $(OFLAGS) -O2 -ffast-math -fomit-frame-pointer SFLAGS = $(WFLAGS) ifndef SYMBOLMODE ifdef STATICLINK LFLAGS += -s endif LIB_FLAGS = `allegro-config --libs release $(ALLEGRO_CONFIG_FLAGS)` endif endif endif CFLAGS += -fno-common -pipe ifdef ADIME_DEVELOPING CFLAGS += -D_ADIME_DEVELOPING=1 endif ifdef ADIME_FORTIFY CFLAGS += -D_ADIME_FORTIFY=1 -DFORTIFY endif CFLAGS_NO_OPTIMIZE = $(WFLAGS) COMPILE_FLAGS = $(subst src/,-DADIME_SRC ,$(findstring src/, $<))$(CFLAGS) COMPILE_FLAGS_NO_OPTIMIZE = $(subst src/,-DADIME_SRC ,$(findstring src/, $<))$(CFLAGS_NO_OPTIMIZE) ifdef STATICLINK COMPILE_FLAGS += -DADIME_STATICLINK endif ifdef PROFILEMODE LIB_FLAGS += -lgmon endif # -------- List platform specific objects and programs. -------- VPATH += OBJ_LIST = $(COMMON_OBJS) # Insert names of targets to build platform specific programs here. PROGRAMS = # Insert targets to build platform specific programs here. # myprogram: path/myprogram$(EXE_SUFFIX) # -------- Define how to compile. -------- GCC2UNIX = -D__APPLE__ -UDJGPP -U__UNIX__ COMPILE_C_TO_OBJ_DEPS = define COMPILE_C_TO_OBJ gcc $(COMPILE_FLAGS) -I./include -o $@ -c $< endef define COMPILE_C_TO_OBJ_NO_OPTIMIZE gcc $(COMPILE_FLAGS_NO_OPTIMIZE) -I./include -o $@ -c $< endef COMPILE_S_TO_OBJ_DEPS = define COMPILE_S_TO_OBJ gcc $(SFLAGS) -I./include -x assembler-with-cpp -o $@ -c $< endef ifdef STATICLINK # link as a static library LINK_LIB_DEPS = define LINK_LIB ar rs $(LIB_NAME) $(LIB_OBJS) endef LINK_EXE_DEPS = define LINK_EXE gcc $(LFLAGS) -o $@ $< -L$(LIB_DIR) -ladime_s $(LIB_FLAGS) endef LINK_EXE_ALL_DEPS = define LINK_EXE_ALL gcc $(LFLAGS) -o $@ $^ -L$(LIB_DIR) -ladime_s $(LIB_FLAGS) endef else # link as a shared object LINK_LIB_DEPS = define LINK_LIB gcc $(LFLAGS) -dynamiclib -prebind -seg1addr 0x20000000 -single_module -o $(IMPLIB_NAME) $(LIB_OBJS) $(LIB_FLAGS) endef LINK_EXE_DEPS = define LINK_EXE gcc $(LFLAGS) -o $@ $< $(IMPLIB_NAME) $(LIB_FLAGS) endef LINK_EXE_ALL_DEPS = define LINK_EXE_ALL gcc $(LFLAGS) -o $@ $^ $(IMPLIB_NAME) $(LIB_FLAGS) endef endif # ifdef STATICLINK LINK_EXE_NOLIB_DEPS = define LINK_EXE_NOLIB gcc $(LFLAGS) -o $@ $< endef LINK_EXE_ALL_NOLIB_DEPS = define LINK_EXE_ALL_NOLIB gcc $(LFLAGS) -o $@ $^ endef # -------- Rules for installing and removing the library files. -------- # If you don't have the install command, you may use cp and mkdir, but # this will not set permissions. $(SYSTEM_LIB_DIR)/$(IMPLIB_BASENAME): $(IMPLIB_NAME) install -m 755 -d $(SYSTEM_LIB_DIR) install -m 644 $< $@ $(RUN_RANLIB) $(SYSTEM_INCLUDE_DIR)/adime.h: include/adime.h install -m 755 -d $(SYSTEM_INCLUDE_DIR) install -m 644 $< $@ $(SYSTEM_INCLUDE_DIR)/adime/%.h: include/adime/%.h include/adime install -m 755 -d $(SYSTEM_INCLUDE_DIR)/adime install -m 644 $< $@ INSTALL_HEADERS = $(addprefix $(SYSTEM_DIR)/,$(wildcard include/adime/*.h)) INSTALL_FILES = $(SYSTEM_LIB_DIR)/$(IMPLIB_BASENAME) \ $(SYSTEM_INCLUDE_DIR)/adime.h \ $(INSTALL_HEADERS) install: $(INSTALL_FILES) @echo The $(DESCRIPTION) Mac OS X library has been installed. @echo Run sudo make install-man to install the man pages. @echo Run sudo make install-info to install the info documentation. @echo Run sudo make install-framework to install Adime as framework. @echo Run sudo make install-template to install Adime as ProjectBuilder and XCode template. @echo You may conserve space by instead running @echo sudo make install-gzipped-man and/or sudo make install-gzipped-info. install-framework: $(FRAMEWORK) $(FRAMEWORK): $(LIB_NAME) ifdef STATICLINK @echo You need to compile Adime as a dynamic library to install the framework. else @rm -fr $(FRAMEWORK) @mkdir $(FRAMEWORK) @mkdir -p $(FRAMEWORK)/Versions/$(shared_version)/Headers @mkdir -p $(FRAMEWORK)/Versions/$(shared_version)/Resources ifdef EMBED gcc $(LFLAGS) -dynamiclib -prebind -seg1addr 0x20000000 -single_module $(INSTALL_NAME_EMBED) -o $(FRAMEWORK)/Versions/$(shared_version)/$(FRAMEWORK_NAME) $(LIB_OBJS) -framework Allegro else @cp $(LIB_NAME) $(FRAMEWORK)/Versions/$(shared_version)/$(FRAMEWORK_NAME) endif @cp include/adime.h $(FRAMEWORK)/Versions/$(shared_version)/Headers @cp -r include/adime $(FRAMEWORK)/Versions/$(shared_version)/Headers @(cd $(FRAMEWORK)/Versions; ln -s $(shared_version) Current) @(cd $(FRAMEWORK); ln -s Versions/Current/Headers $(FRAMEWORK)/Headers) @(cd $(FRAMEWORK); ln -s Versions/Current/Resources $(FRAMEWORK)/Resources) @(cd $(FRAMEWORK); ln -s Versions/Current/$(FRAMEWORK_NAME) $(FRAMEWORK)/$(FRAMEWORK_NAME)) @sed -e "s/@NAME@/$(FRAMEWORK_NAME)/" misc/Info.plist >temp @sed -e "s/@VERSION@/$(shared_version) ($(DESCRIPTION))/" temp >$(FRAMEWORK)/Resources/Info.plist @rm -f temp ifdef EMBED @echo "This is the embeddable version of the Adime framework" > $(FRAMEWORK)/Resources/Embeddable endif @echo The $(FRAMEWORK_DESCRIPTION) Adime framework has been successfully installed in: @echo $(FRAMEWORK) endif install-template: $(TEMPLATE) $(TEMPLATE): $(FRAMEWORK) @rm -fr $(TEMPLATE) @mkdir -p $(TEMPLATE)/AdimeApp.pbproj @cp misc/template.c $(TEMPLATE)/main.c @cp misc/TemplateInfo.plist $(TEMPLATE)/AdimeApp.pbproj @cp misc/project.pbxproj $(TEMPLATE)/AdimeApp.pbproj @cp misc/project.pbxuser $(TEMPLATE)/AdimeApp.pbproj @echo "Adime application template for Project Builder (XCode) installed in:" @echo $(TEMPLATE) install-info: docs @echo Installing Adime info documentation... ./misc/mkdirs.sh $(SYSTEM_INFO_DIR) @install -c -m 644 docs/info/adime.info $(SYSTEM_INFO_DIR) -@if $(SHELL) -c "$(INSTALL_INFO) --version" >/dev/null 2>&1; then \ if $(INSTALL_INFO) --version 2>&1 | grep "Debian" >/dev/null; then \ $(INSTALL_INFO) --section Development -- $(SYSTEM_INFO_DIR)/adime.info; \ else \ $(INSTALL_INFO) $(SYSTEM_INFO_DIR)/adime.info $(SYSTEM_INFO_DIR)/dir; \ fi; \ else \ true; \ fi install-gzipped-info: install-info @echo Compressing documentation... @gzip -9 -f $(SYSTEM_INFO_DIR)/adime.info install-man: docs ./misc/mkdirs.sh $(SYSTEM_MAN_DIR)/man3 @for file in docs/man/*.3; do \ echo Installing $$file to $(SYSTEM_MAN_DIR)/man3; \ install -c -m 644 $$file $(SYSTEM_MAN_DIR)/man3/; \ done install-gzipped-man: docs ./misc/mkdirs.sh $(SYSTEM_MAN_DIR)/man3 @for file in docs/man/*.3; do \ echo Installing $$file.gz to $(SYSTEM_MAN_DIR)/man3; \ install -c -m 644 $$file $(SYSTEM_MAN_DIR)/man3/; \ gzip -9 -f $(SYSTEM_MAN_DIR)/man3/`echo $$file | sed -e "s:.*/::"`; \ done UNINSTALL_FILES = $(SYSTEM_LIB_DIR)/libadime.a $(SYSTEM_LIB_DIR)/libadimd.a \ $(SYSTEM_LIB_DIR)/libadime_s.a $(SYSTEM_LIB_DIR)/libadimd_s.a \ $(SYSTEM_LIB_DIR)/libadime.dylib $(SYSTEM_LIB_DIR)/libadimd.dylib \ $(SYSTEM_INCLUDE_DIR)/adime.h $(SYSTEM_INCLUDE_DIR)/adime/*.h \ $(SYSTEM_MAN_DIR)/man3/* $(SYSTEM_INFO_DIR)/adime.info # $(WINDIR_U)/adime$(LIB_VERSION).dll $(WINDIR_U)/adid$(LIB_VERSION).dll uninstall: -rm -fv $(UNINSTALL_FILES) -rmdir $(SYSTEM_INCLUDE_DIR)/adime -rm -fr $(FRAMEWORK) -rm -fr $(TEMPLATE) @echo All gone! # -------- Compile anything that can't be done in makefile.all. -------- #examples/ex%: $(OBJ_DIR)/ex%$(OBJ_SUFFIX) # $(LINK_EXE) # #NATIVE_LINK_EXE = 1 # -------- generate automatic dependencies -------- DEPEND_PARAMS = $(GCC2UNIX) -MM -MG -I./include -DADIME_SCAN_DEPEND depend: gcc $(DEPEND_PARAMS) src/*.c examples/*.c misc/makedoc/*.c > _depend.tmp sed -e "s/^[a-zA-Z0-9_\/]*\///" -e "s/[^ ]*version\.h//" -e "s/[^ ]*djgpp\.ver//" -e "s/[^ ]*allegro[^ ]*//g" -e'/^ *\\/d' _depend.tmp > _depend2.tmp sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/macosx\/adime\/\1\.o:/" _depend2.tmp > obj/macosx/adime/makefile.dep sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/macosx\/adimd\/\1\.o:/" _depend2.tmp > obj/macosx/adimd/makefile.dep sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/macosx\/adime_s\/\1\.o:/" _depend2.tmp > obj/macosx/adime_s/makefile.dep sed -e "s/^\([a-zA-Z0-9_]*\)\.o:/obj\/macosx\/adimd_s\/\1\.o:/" _depend2.tmp > obj/macosx/adimd_s/makefile.dep rm _depend.tmp _depend2.tmp