No description
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Ezra Hradecky 2c89e7f85e 1.0.2
2020-11-06 15:58:23 -05:00
inc 1.0.0 2020-07-22 12:35:55 -04:00
lib 1.0.0 2020-07-22 12:35:55 -04:00
src 1.0.0 2020-07-22 12:35:55 -04:00
CHANGELOG.md 1.0.2 2020-11-06 15:58:23 -05:00
LICENSE Added License 2020-07-22 12:49:32 -04:00
makefile 1.0.2 2020-11-06 15:58:23 -05:00
README.md Fix README.md 2020-07-22 16:40:05 +00:00

Universal C Makefile

This makefile should allow it's users to compile C code to Linux or Windows from Linux.

You may compile for Linux or Windows, 32 or 64 bit, easily! Both executables and libraries, static or dynamic.

Usage

Project Structure

This makefile respects a specific file structure to help ease organisation of compilation.

.
├── build
│   └── <OS>
│       └── <CPU>
│           ├── output.a / output.lib
│           ├── output.out / output.exe
│           ├── output.so / output.dll
│           └── src
│               ├── *.c.d
│               └── *.c.o
├── inc
│   └── *.h
├── lib
│   └── <OS>
│       └── <CPU>
│           └── *.a / *.lib
├── makefile
└── src
    ├── *.c
    └── *.h

Basically:

  • Place all your source files in ./src/
  • Place all your includes in ./include/
  • Place all your libraries in ./lib/[OS]/[CPU]/

Once you make your project, all compiled files will end up in ./build/[OS]/

Preparing the makefile

Before compiling your project, you could set a couple of flags if you plan on using libraries or generating debug information.

Making Executables

make TARGET_OS=<linux/windows> TARGET_CPU=<i686/x86_64>

Making Libraries

make TARGET_OS=<linux/windows> TARGET_CPU=<i686/x86_64> ARCHIVE=<true/false> ARCHIVE_STATIC=<true/false>