I have the source code that I worked in at the end of the 90s-2000, and all of its backups, except for the make file (yes, kill, bad backups are almost as good as no backups): so .. I wonder if there is any automated way to create a makefile or a good way to quickly analyze dependencies?
In particular, I am looking for:
- a tool that can analyze dependencies and adjust the order of links for me.
- If this does not exist, then the council greatly appreciates how best to approach this problem for someone who has had a similar problem in the past
- without completing either of the above two options, I think the best approach is to create a tool for creating analysis / creating files that can automatically generate the order of dependencies for binding (I settled on this approach, because time is always a short sentence to compress in another project )
The reason for this search for reference / advice is that the codebase is 300,000 lines of code (excluding comments) and covers hundreds of C / O files and as often as I tried to create a make file manually, it frustrates and mixes, therefore my last try to ask for help and ask here.
For reference: I tried Cmake , AutoMake, GenMake and similar tools in the past to create a makefile, all to no avail, because the dependencies are terrible.
script
, makefile, C ++, :
$(VERBOSE).SILENT:
PROGRAMNAME = prog
CC = gcc
CC += -c
CPP = g++
CPP += -c
ASM = nasm
ASM += -f elf -d ELF_TYPE
LD = g++
OBJFILES = $(patsubst %.c,%.o,$(wildcard *.c))
OBJFILES += $(patsubst %.s,%.o,$(wildcard *.s))
OBJFILES += $(patsubst %.cpp,%.o,$(wildcard *.cpp))
all: $(PROGRAMNAME)
clean:
@echo "Cleaning object files"
@echo " rm -f *.o"
rm -f *.o
@echo "Cleaning backups"
@echo " rm -f *~"
rm -f *~
@echo "Removing program file"
@echo " rm -f "$(PROGRAMNAME)
rm -f $(PROGRAMNAME)
%.o: %.s
@echo "Assembling ASMs "$@
@echo " ASM "$<
$(ASM) $<
%.o: %.c
@echo "(C)ompiling "$@
@echo " CC "$<
$(CC) $<
%.o: %.cpp
@echo "(C++)ompiling "$@
@echo " CPP "$<
$(CPP) $<
$(PROGRAMNAME): $(OBJFILES)
@echo "Get ready...."
@echo "Linking "$@
@echo " LD -o "$(PROGRAMNAME)" "$(OBJFILES)
$(LD) -o $(PROGRAMNAME) $(OBJFILES)
@echo "Cry if it worked! Scream swear and cry if it did not..."
strip: $(PROGRAMNAME)
@echo "Stripping "$(PROGRAMNAME)
echo -n "Size of "$(PROGRAMNAME)" before stripping is "
ls -sh $(PROGRAMNAME) | cut -d' ' -f1
@echo " Stripping "$(PROGRAMNAME)
strip $(PROGRAMNAME)
echo -n "Size of "$(PROGRAMNAME)" after stripping is "
ls -sh $(PROGRAMNAME) | cut -d' ' -f1
nothing:
@echo "Nothing to do; see you later - I'm going home!!!"
@echo "Hey, try some of these:"
@echo "make all - this would be the one you want"
@echo "make strip - does not work in the real world, only in computers"
@echo "make clean - will help clean your mind up"