Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
guide:makefile [2024/07/18 09:46]
rajit created
guide:makefile [2024/07/22 08:50] (current)
rajit [Standard test cases]
Line 1: Line 1:
 ====== The standard ACT Makefile structure ====== ====== The standard ACT Makefile structure ======
 +
 +The following is a simple ''Makefile'' that uses the ACT standard makefile to create an executable called ''example'', and which links against the core ACT library as well as the default passes.
 +
 +<code>
 +BINARY=example.$(EXT)
 +
 +TARGETS=$(BINARY)
 +
 +OBJS=main.o 
 +SRCS=$(OBJS:.o=.cc)
 +
 +include $(ACT_HOME)/scripts/Makefile.std
 +
 +$(BINARY): $(LIB) $(OBJS) $(ACTPASSDEPEND)
 +        $(CXX) $(CFLAGS) $(OBJS) -o $(BINARY) $(LIBACTPASS)
 +
 +-include Makefile.deps
 +</code>
 +
 +The variable ''EXT'' is set to an extension that combines the architecture and operating system. So this might look something like ''arm64_darwin23_5_0'' for an Apple M-series Mac, or ''x86_64_linux5_15_0'' on an x86 Linux platform. The  makefile creates a directory called ''$(EXT)'', and the object files generated are placed in that directory.((This was originally designed for Unix clusters with heterogeneous architectures but a shared file system.))
 +
 +Standard targets defined are:
 +   * ''make depend'': creates ''Makefiles.dep'' with dependencies.
 +   * ''make'': this should build the executable
 +   * ''make install'': installs all files into ''$(ACT_HOME)''
 +   * ''make clean'': removes object files but keeps all targets that were built
 +   * ''make realclean'': removes targets as well (in addition to what is done with just clean).
 +
 +The object files can be moved into the working directory using:
 +<code>
 +$ make move-in
 +</code>
 +They can be put back into the architecture-specific directory using:
 +<code>
 +make move-out
 +</code>
 +
 +===== Changing compilers =====
 +
 +The variables ''CC'' and ''CXX'' can be changed to modify the default C and C++ compilers respectively.
 +So:
 +<code>
 +$ make CXX=clang++
 +</code>
 +will use clang++ as the C++ compiler for the build.
 +
 +===== Debug builds =====
 +
 +The C/C++ compilers are passed the ''C_COMPILER_OPTIONS'' environment variable. This is normally set to ''-O2'', but can be set to ''-g'' during the build process like this:
 +<code>
 +$ make C_COMPILER_FLAGS=-g
 +</code>
 +
 +
 +===== Standard test cases =====
 +
 +Standard test cases can be run using:
 +<code>
 +$ make runtest
 +</code>
 +
 +For this to work properly, create test cases for your tool in the following way:
 +   * All test cases and sample outputs are in the ''test/'' sub-directory.
 +   * Test cases are run by changing to the ''test/'' sub-directory and running the script ''run.sh''. If this script doesn't exist, then nothing happens.
 +Take a look at examples from existing ACT tools (e.g. ''[[https://github.com/asyncvlsi/actsim/tree/master/test|actsim]]'').
 +