Makefile instructions to create directories (CentOS7 , GNU Make 3.82)
Hello,
My makefiles are set up to generate an environment specific build directory based on the local configuration and some values passed to make. It generally looks like,
Code:
# compilers, may be passed to make
CC++ = g++
FCOMP = gfortran
# version of program, may be passed to make
ver = debug
# manually assign linux distro
OS=CentOS-7.7
# collect name information
ARCH := $(shell uname -m)
KERN := $(shell uname -r | cut -d. -f 1,2)
# find g++ compiler version
# this can vary with the distribution
CMP := $(shell g++ --version | cut -d ' ' -f 3 | sed q)
# create names for build directory name
CNAME := gpp-$(CMP)
FNAME := gfortran-$(CMP)
# archdir is executed as part of all and will create the necessary
# version specific directories if they do not exist
archdir: ${BDIR}
# concatenate the name for the build directory
BDIR := bld_$(OS)_$(KERN).$(ARCH)_$(CNAME)_$(FNAME)_$(ver)
# mkdir if the directories do not exist
${BDIR}:
@mkdir -p ${BDIR}
# archdir is part of all
all archdir program_name
When make is called with all, all runs archdir, archdir runs BDIR and the build directory gets created if it does not exist. This has generally worked well.
Recently I wanted to create some additional directories and so attempted to implement the same method.
I added a new directory name and instruction to make the directory. That instruction was added to archdir so that the resulting code looks like,
Code:
# archdir is executed as part of all and will create the necessary
# version specific directories if they do not exist
archdir: ${BDIR} ${TESTDIR}
# create name for the build directory
BDIR := bld_$(OS)_$(KERN).$(ARCH)_$(CNAME)_$(FNAME)_$(ver)
# mkdir if the directories do not exist
${BDIR}:
@mkdir -p ${BDIR}
# create name for test directory
TESTDIR = ./test/(OS)_$(KERN).$(ARCH)_$(CNAME)_$(FNAME)_$(ver)
# mkdir if the directory does not exist
${TESTDIR}:
@mkdir -p ${TESTDIR}
The directory ./test/ already exists. When I run the make file with all, the build completes without error but the new directory $TESTDIR is not created.
Any suggestions as to what I am missing here? Do I have a syntax issue? Is something out of order?
Some of this could probably be better done with a config script since there is no way that I know of to collect all of the above from every version of linux and windows with the same code. Sometimes I think it just makes more sense to pass values in the call to make or hard code the make file. Making up a directory name and creating the directory is something I think I should be able to do.
hello!
i want to create a Makefile on the freebsd 4.5,so i vi the hello.c
#include
int main(int argc, char** argv)
{
printf(''Hello, GNU!\n'');
return 0;
}
#autoscan
#cp configure.scan configure.in
#vi configure.in
modify:AC_OUTPUT AC_OUTPUT(Makefile)
#aclocal
#autoconf... (0 Replies)
Hi,
This stems from the following thread https://www.unix.com/showthread.php?t=18299
I have a makefile which makes either executables or a shared library.
i.e. make -f unix.mak will create the executables and
make -f unix.mak libolsv will create the shared library.
Since these have to be... (4 Replies)
Hi ,
I 'm trying to check if multiple directories exist on a server, if not create the missing ones and print " creating missing directory.
how to write this in a simple script, I have made my code complex
if ; then
taskStatus="Schema extract directory exists, checking if SQL,Count and... (7 Replies)
Hello everybody,
Currently I'm learning how to build projects (C programming) with GNU make. I have a problem with one Makefile and I would appreciate if you could kindly give me a hand. Here is the environment:
OS: Redhat linux 5
compiler: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-44)... (2 Replies)
hi all,
I have written a simple C program hello.c and a Makefile.ac but when i try to run automake it does not create Makefile.in hence I am not able to run ./configure command in my directory. Following are the containts of my prog.
hello.c
--------
Code:
#include<stdio.h>
main()
{... (0 Replies)
I am trying to create a makefile to build a program and am getting the following error:
make -f tsimplex.mk
make: *** No rule to make target `/main/tsimplex_main.cpp', needed by `tsimplex_main.o'. Stop.
OPSYS = $(shell uname -s )
TARGET = tsimplex
ROOTDIR = ../../..
GTSDIR =... (1 Reply)
I've created a tag in the makefile:
mytag: $(shell ${PWD}/script.sh)
When i do: make clean - the script is executed
When i perform make or make mytag the script is again executed with the output:
make: Nothing to be done for mytag
What i want ?
I want script.sh to be executed only... (0 Replies)
1. The problem statement, all variables and given/known data:
Create a makefile for a set of source files. Several sources files are given but we are not allowed to modify them. The goal is to create a makefile such that if a change is made to any of the source code files, the project can be... (5 Replies)
I am new to Solaris and compilation using make files.
I have a code base which is organized into different folders. At the root folder is a master make file and in the sub directories, there are make files for that particular folder.
In the make files present in subdirectories, I am seeing... (2 Replies)