Skip to main content

Creating Symbols in Make file

So, let us make our file make file more nice ...

Now we will assign symbols, and some targets as well

mobi.mk
CC=gcc
OUT=mobi.exe
TARGET=main

build:
    $(CC)  $(TARGET).o -o $(OUT)

compile:
    $(CC) -c $(TARGET).c

clean:
    rm -f *.o $(OUT)

now try this nice command...

$ make -f ./mobi.mk clean compile build
rm -f *.o mobi.exe
gcc -c main.c
gcc  main.o -o mobi.exe

It is better to create a compilation of a module separate when working on it and compile that target only instead of compiling everything...

So, for so looks good...

Let's add the all target

mobi.mk
CC=gcc
OUT=mobi.exe
TARGET=main

all: clean compile build

build:
    $(CC)  $(TARGET).o -o $(OUT)

compile:
    $(CC) -c $(TARGET).c

clean:
    rm -f *.o $(OUT)


Now, we don't have to specify the targets...

$ make -f ./mobi.mk

rm -f *.o mobi.exe
gcc -c main.c
gcc  main.o -o mobi.exe

Comments

Popular posts from this blog

Culture Information and Localization in .NET

Namespace: System.Globalization CultureInfo Class:                 It provides information like the Format of numbers and dates, Culture’s Calendar, Culture’s language and sublanguage (if applicable), Country and region of the culture. The Basic use of CultureInfo class is shown here: • How string Comparisons are performed • How Number Comparison & Formats are performed • Date Comparison and Formats. • How resources are retrieved and used. Cultures are grouped into three categories: Invariant Culture : It’s Culture Insensitive. It can be used to build some trial application. It can be also used to build an application with hard-coded expiry date that ignores cultures. But using it for every comparison will be incorrect and inappropriate. Neutral Culture : English(en), Frensh(fr), and Spanish(sp). A neutral culture is related to language but it’s not related to specific regi...

Using ADO.NET Transaction Object, Saving CLR Objects and SqlNotificationRequest

Serializable allows one transaction to complete before the other start. SqlConnectoin support named savpoint to roll back to; that’s an equaliant to save transaction command in MS SQL Server. Using TransactionScope Object : A transaction can’t span multiple connections.   Local and distributed transaction ares supported in 1.x you have to Enterpeise seveices library to regiser multiple connections and then call EnlistDistributedTransaction. Distributed Transaction Coordinator is required for Distributed transaction that’s available on windows 2000 & +. In 2.X and later use TransactionScope object. Serializable allows one transaction to complete before the other start. SqlConnectoin support named savpoint to roll back to; that’s an equaliant to save transaction command in MS SQL Server. Using TransactionScope Object : Dispoase of the transaction must be called to complete the transaction. Distributed Transaction : ...

Creating a New Programming Language and Compiler

Recently I have been looking into a special need to create my own programming language. I have also studied the history of different languages and success and issues they are struggling and stuck with. Here is my personal point of view on this: Creating a Purely new Programming Language The best available language is C\C++ for a cross platform development with different compilers and debuggers. If you are thinking of creating a remarkable new language, HOLD ON,          1- You need to create a compile to target X86, X64, and ARM etc          2- Compiler shall work on Windows, Linux and MAC etc...          3- You need to revisit the entire history of programming language in this case and you have to port all that stuff          4- You Need IDE, compiler          5- Debugger ...