Apply patch from Daniel Schürmann: https://sourceforge.net/p/boomerang/bugs/78/
[boomerang.git] / boomerang / loader / Makefile.am
blobd4c7386d2eeabd1087d9ae89ebc4cae6ec9c4e57
1 ######################################################
2 # File: Makefile
4 # Desc: Makefile for the Loader library files.
5 #   This loader is lightly adapted from the loader in UQBT
6 #   Purpose is to load the input binary file into memory, with calls to iterate through sections,
7 #       find entry points, symbols, etc.
8 #   The main library is BinaryFile, which calls eactly one of ElfBinaryFile etc as needed.
10 # Prerequisite libraries: none
12 ######################################################
14 # $Revision: 1.2 $
15 # Note: gnu make is probably required (for patsubst etc)
16 # This whole makefile is dependent on finding the pattern *BinaryFile.cpp; a lib%.so file is made for each of these
17 # You should be able to add a simple loader without any changes to this Makefile, as long as you follow the naming
18 # convention <type>BinaryFile.*
20 # 24 Nov 08 - Markus Gothe - Automake
21 # 22 Aug 06 - Mike Frysinger: respect values set up by ./configure script
22 # 12 Jul 05 - Mike: All use SymTab.o now
23 # 20 Jul 04 - Mike: Removed BOOMDIR (paths relative now)
24 # 12 Apr 05 - Gerard: Structured
25 # 11 Apr 02 - Mike: Use lib%.so names and -l now; no "make install" any more
27 AUTOMAKE_OPTIONS = foreign
29 ####################
30 # Compiler settings
33 FPIC = -fPIC
36 ####################################
37 # Detection of OS specific settings
40 #EXEEXT=$(EXEEXT)
41 #DLLEXT=$(OBJEXT)
42 if HOST_WINDOWS
43  WININCLUDE=-Iwin32make/include
44  # RUNPATH is not needed on Windows 
45 # RUNPATH=
46  COPYDLL=$(top_srcdir)/libBinaryFile.$(OBJEXT)
47 #else
48  # Non-Windows
49 # LDL=-ldl
50 #if HOST_GNU_LD
51 # RUNPATH=-Wl,-rpath -Wl,"lib"
52 #endif
53 endif
55 ######################
56 # Rules for compiling
59 LOADERS = \
60         ElfBinaryFile.cpp \
61         Win32BinaryFile.cpp \
62         ExeBinaryFile.cpp \
63         HpSomBinaryFile.cpp \
64         PalmBinaryFile \
65         DOS4GWBinaryFile.cpp \
66         IntelCoffFile.cpp \
67         $(NULL)
69 pkglib_LTLIBRARIES = 
71 if HOST_CYGWIN
72  LOADERS+=
73 else
74  # Until we can resolve the issue of compiling loader/MachOBinaryFile.cpp, don't attempt to make it so at least
75  # the Cygwin hosted Boomerang can compile and use non-MachO loaders
76  LOADERS+=MachOBinaryFile.cpp
77 endif
78 LOADERDLLS=$(patsubst %,$(top_srcdir)/lib/lib%$(OBJEXT),$(LOADERS))
79 BASEDLL=$(top_srcdir)/lib/libBinaryFile$(OBJEXT)
80 ALLDLLS=$(LOADERDLLS) $(BASEDLL)
81 ALLLIBS=$(patsubst %,-l%,$(LOADERS)) -lBinaryFile
82 ALLOBJS = $(patsubst %, %.o, $(LOADERS))
83 ALLOBJS += BinaryFile.o SymTab.o
85 all: $(ALLDLLS) $(COPYDLL) BinaryFileFactory.$(OBJEXT) BinaryFileStub.$(OBJEXT)
87 microX86dis.$(OBJEXT): microX86dis.c
88         $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $(FPIC) $<
90 # Extra object files, etc
91 # These are target specific variables.
92 $(top_srcdir)/lib/libWin32BinaryFile.$(OBJEXT): EXTRAS = microX86dis.$(OBJEXT)
93 $(top_srcdir)/lib/libWin32BinaryFile.$(OBJEXT): microX86dis.$(OBJEXT)
94 $(top_srcdir)/lib/libDOS4GWBinaryFile.$(OBJEXT): EXTRAS = microX86dis.$(OBJEXT)
95 $(top_srcdir)/lib/libDOS4GWBinaryFile.$(OBJEXT): microX86dis.$(OBJEXT)
97 $(top_srcdir)/libBinaryFile.$(OBJEXT): $(top_srcdir)/lib/libBinaryFile.$(OBJEXT)
98         cp $< $@
100 BinaryFile.o:           CCEXTRAS = -DBUILDING_LIBBINARYFILE
101 MachOBinaryFile.o:      CCEXTRAS = -I.
103 $(BASEDLL) : BinaryFile.$(OBJEXT) SymTab.$(OBJEXT)
104         $(CXX) $(CXXFLAGS) -o $@ $(SHARED) BinaryFile.$(OBJEXT) SymTab.$(OBJEXT) $(OUTIMPLIB) $(LDFLAGS)
106 # This pattern generates all the main dependencies
107 $(LOADERDLLS): $(top_srcdir)/lib/lib%.$(OBJEXT) : %.$(OBJEXT) $(BASEDLL)
108         $(CXX) $(CXXFLAGS) -o $@ $(SHARED) $< SymTab.o $(EXTRAS) -lBinaryFile $(RUNPATH) -L$(top_srcdir)/lib $(LDFLAGS)
110 # Compile all objects with -fPIC
111 $(ALLOBJS): %.$(OBJEXT) : %.cpp
112         $(CXX) $(CXXFLAGS) -c $(FPIC) $(CCEXTRAS) -I$(top_srcdir)/include -o $@ $<
114 ####################
115 # Conditional rules
118 # Automatic generation of dependencies
119 if MAKEDEPEND
120 # automatic is better!
121 depend: $(MAKEDEPEND)
122         $(MAKEDEPEND) -w120 -Y -I$(top_srcdir)/include -I. -I$(top_srcdir)/c -I$(top_srcdir)/codegen \
123         -I$(top_srcdir)/frontend *.cpp *.c > /dev/null 2>&1
125 depend.in: $(MAKEDEPEND)
126         $(MAKEDEPEND) -fMakefile.in -w120 -Y -I$(top_srcdir)/include -I. -I$(top_srcdir)/c -I$(top_srcdir)/codegen \
127         -I$(top_srcdir)/frontend *.cpp *.c > /dev/null 2>&1
128 else
129 depend:
130 @echo You need the (X11) makedepend tool to generate dependencies
131 depend.in:
132 @echo You need the (X11) makedepend tool to generate dependencies
133 endif
135 ###############
136 # Unit testing
139 testLoader$(EXEEXT): testLoader.$(OBJEXT) LoaderTest.$(OBJEXT) microX86dis.$(OBJEXT) BinaryFileFactory.$(OBJEXT) SymTab.$(OBJEXT)
140         $(CXX) $(CXXFLAGS) -o $@ $^  -lcppunit $(ALLLIBS) $(RUNPATH) $(LDL) -L$(top_srcdir)/lib $(LDFLAGS)
142 testLoader.$(OBJEXT): testLoader.cpp
143         $(CXX) $(CXXFLAGS) -c -o $@ -I$(top_srcdir)/include $<
145 LoaderTest.$(OBJEXT): LoaderTest.cpp LoaderTest.h $(top_srcdir)/include/BinaryFile.h SymTab.$(OBJEXT)
146         $(CXX) $(CXXFLAGS) -c -o $@ -I$(top_srcdir)/include $<
148 # Because of the relative paths, testLoader will only work from the parent
149 # directory...
150 test: all testLoader$(EXEEXT)
151         cd $(top_srcdir) && loader/testLoader$(EXEEXT)