boost=/opt/local/include/boost-1_34_1 out=../build obj=../build/obj O=.o E= .SUFFIXES: .SUFFIXES: .cpp $(O) CXX=g++ ifneq ($(wildcard /sbin/bsdlabel),) OSTYPE=freebsd endif ifneq ($(wildcard /System/Library/Extensions/AppleFileSystemDriver.kext),) OSTYPE=darwin endif #LDFLAGS=-lc -lstdc++-static -lsupc++ #LDFLAGS=-lc -lstdc++.6 -lsupc++ LDFLAGS=-L/usr/local/lib ifeq ($(OSTYPE),darwin) LDFLAGS=-L$(boost)/lib -L/opt/local/lib /Library/Frameworks/MissingSyncWM.framework/Versions/A/MissingSyncWM endif LDFLAGS+= -g -liconv CFLAGS+= -g # somehow wchar defaults to 32bit ifeq ($(OSTYPE),freebsd) CFLAGS+= -fshort-wchar endif CFLAGS+= -I ../common -I ../include/win32 -I ../include -I ../dll -I /usr/local/include CFLAGS+= -D_GCC -DITSUTILS CFLAGS+= -I/Library/Frameworks/MissingSyncWM.framework/Versions/A/Headers LD=$(CXX) define compile @"$(CXX)" $(CFLAGS) $(cflags_$(basename $(notdir $1))) -c "$2" -o "$1" endef $(obj)/%$(O): %.cpp $(call compile,$@,$<) $(obj)/%$(O): ../common/%.cpp $(call compile,$@,$<) $(out)/%: $(obj)/%$(O) @"$(LD)" $(LDFLAGS) $(ldflags_$(basename $(notdir $@))) $^ -o "$@$(E)" ifeq ($(OSTYPE),freebsd) some: $(obj) $(out)/dump$(E) endif ifeq ($(OSTYPE),darwin) some: $(obj) $(out)/dump$(E) $(out)/pdir$(E) $(out)/psendsms$(E) $(out)/pdial$(E) # $(out)/pput$(E) endif $(obj): mkdir -p $(obj) define compilerule $(obj)/$1: $2 $$(call compile,$$@,$$<) endef define buildtarget APPLIST+=$1 CLEANLIST+=$(out)/$1 CLEANLIST+=$(addprefix $(obj)/,$2) $(out)/$1: $(addprefix $(obj)/,$2) endef define copyfile APPLIST+=$1 CLEANLIST+=$(out)/$1 $(out)/$1: $(out)/$2 cp $$^ $$@ endef #$(call buildtarget,tstaudio$(E), tstaudio$(O) debug$(O) stringutils$(O) winmm.lib) define buildrules $(call compilerule,umemdump$(O),pmemdump.cpp) cflags_umemdump=-DUNIXMEMDMP $(call compilerule,debugnorapi$(O),../common/debug.cpp) cflags_debugnorapi=-D_NO_RAPI $(call compilerule,ppostmsg$(O),ppostmsg.cpp) cflags_ppostmsg=-DWINCEPOSTMSG $(call compilerule,postmsg$(O),ppostmsg.cpp) cflags_postmsg=-DWIN32POSTMSG $(call compilerule,pmemdump$(O),pmemdump.cpp) cflags_pmemdump=-DWINCEMEMDMP $(call compilerule,memdump$(O),pmemdump.cpp) cflags_memdump=-DWIN32MEMDMP $(call compilerule,pregutl$(O),pregutl.cpp) cflags_pregutl=-DWINCEREGUTL $(call compilerule,regutl$(O),pregutl.cpp) cflags_regutl=-D_UNICODE -DUNICODE -DWIN32REGUTL $(call compilerule,sdread$(O),psdread.cpp) cflags_sdread=-D_NO_RAPI $(call compilerule,psetmem$(O),psetmem.cpp) cflags_psetmem=-DWINCESETMEM $(call compilerule,setmem$(O),psetmem.cpp) cflags_setmem=-DWIN32SETMEM $(call copyfile,pdocwrite$(E),pdocread$(E)) $(call copyfile,psdwrite$(E),psdread$(E)) $(call copyfile,sdwrite$(E),sdread$(E)) $(call copyfile,pflashrom$(E),pnewbootloader$(E)) $(call buildtarget,dump$(E), dump$(O) debugnorapi$(O) stringutils$(O)) cflags_dump=-D_USE_OPENSSL -I /opt/local/include ldflags_dump=-L/opt/local/lib -lcrypto $(call buildtarget,pps$(E), pps$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pkill$(E), pkill$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,psynctime$(E), psynctime$(O) checkdll$(O) debug$(O) stringutils$(O)) $(if 1, $(call buildtarget,preboot$(E), preboot$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pcoldboot$(E), pcoldboot$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,ppostmsg$(E), ppostmsg$(O) checkdll$(O) debug$(O) stringutils$(O) vectorutils$(O)) $(call buildtarget,postmsg$(E), postmsg$(O) debug$(O) stringutils$(O) vectorutils$(O)) $(call buildtarget,pdel$(E), pdel$(O) csidlpaths$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pmemdump$(E), pmemdump$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,memdump$(E), memdump$(O) checkdll$(O) debug$(O) stringutils$(O) sysint-physmem$(O)) $(call buildtarget,pcalladdr$(E), pcalladdr$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pgsmbuf$(E), pgsmbuf$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pgsmdump$(E), pgsmdump$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pdblist$(E), pdblist$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pcontacts$(E), pcontacts$(O) checkdll$(O) debug$(O) stringutils$(O) vectorutils$(O)) $(call buildtarget,pdir$(E), pdir$(O) csidlpaths$(O) debug$(O) stringutils$(O)) $(call buildtarget,psendsms$(E), psendsms$(O) debug$(O) stringutils$(O)) $(call buildtarget,pdial$(E), pdial$(O) debug$(O) stringutils$(O)) $(call buildtarget,pmkdir$(E), pmkdir$(O) csidlpaths$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pregdmp$(E), pregdmp$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pregutl$(E), pregutl$(O) checkdll$(O) debug$(O) stringutils$(O) vectorutils$(O) FileFunctions$(O)) $(call buildtarget,regutl$(E), regutl$(O) checkdll$(O) debug$(O) stringutils$(O) vectorutils$(O) FileFunctions$(O)) $(call buildtarget,prun$(E), prun$(O) csidlpaths$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,prapi$(E), prapi$(O) checkdll$(O) debug$(O) stringutils$(O) FileFunctions$(O)) $(call buildtarget,pmemmap$(E), pmemmap$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,phandle$(E), phandle$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pdebug$(E), pdebug$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,pdocread$(E), pdocread$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,psdread$(E), psdread$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,sdread$(E), sdread$(O) debugnorapi$(O) stringutils$(O)) $(call buildtarget,psetmem$(E), psetmem$(O) checkdll$(O) debug$(O) stringutils$(O) vectorutils$(O) FileFunctions$(O)) $(call buildtarget,setmem$(E), setmem$(O) checkdll$(O) debug$(O) stringutils$(O) vectorutils$(O) sysint-physmem$(O) FileFunctions$(O)) $(call buildtarget,pcmon$(E), pcmon$(O) debug$(O) stringutils$(O)) $(call buildtarget,pnewbmp$(E), pnewbmp$(O) checkdll$(O) debug$(O) stringutils$(O)) $(call buildtarget,xda2dmp$(E), xda2dmp$(O) debug$(O) stringutils$(O) crc32$(O)) $(call buildtarget,pnewbootloader$(E), pnewbootloader$(O) checkdll$(O) debug$(O) stringutils$(O)) ) endef $(eval $(buildrules)) all: $(obj) $(addprefix $(out)/,$(APPLIST)) clean: $(RM) -f $(CLEANLIST)