From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: * X-Spam-Status: No, score=2.0 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,163994d4f34e92d0 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.58.85.225 with SMTP id k1mr3403396vez.26.1343910254017; Thu, 02 Aug 2012 05:24:14 -0700 (PDT) Path: a15ni8244745qag.0!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-peer1!btnet!zen.net.uk!hamilton.zen.co.uk!xlned.com!feeder3.xlned.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!195.208.113.1.MISMATCH!goblin3!goblin.stu.neva.ru!gegeweb.org!aioe.org!.POSTED!not-for-mail From: "Nasser M. Abbasi" Newsgroups: comp.lang.ada Subject: Re: how to tell gnatmake to send executables to a different directory when compiling multi source? Date: Sun, 29 Jul 2012 23:48:43 -0500 Organization: Aioe.org NNTP Server Message-ID: References: <214bbd15-f7cb-4710-a6a7-64f37923bf4e@googlegroups.com> <87wr1moexq.fsf@ludovic-brenta.org> <87sjcaoa08.fsf@ludovic-brenta.org> Reply-To: nma@12000.org NNTP-Posting-Host: 9ii5QNw33OfeoTzEH8w9ug.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:14.0) Gecko/20120713 Thunderbird/14.0 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-07-29T23:48:43-05:00 List-Id: On 7/29/2012 10:01 PM, Nasser M. Abbasi wrote: > I can just write > > gnatmake -I ... *.adb > > from inside Makefile and that is all. It knows what files to compile > as needed. > For completion's sake, and for future generations :), I thought to show how I ended up doing a simple Makefile that uses gnatmake to build a project. Make is only used here as a 'wrapper' around gnatmake. gnatmake is the one doing the real work. Only reason to use Make is really just so that to avoid using bash scripts and to also allow recusrive make to work (so that I can write make from the top of the tree and have things build). Here is a simple example. Assume you have a folder with 2 main files (main1.adb and main2.adb) and want to build them, and they depend on other ada packages in another folder(s). Then put this Makefile in the folder with the main ada files -------------------------------------- EXECUTABLE=main1 main2 .PHONY: all all: ${EXECUTABLE} .PHONY: FORCE ${EXECUTABLE}: FORCE gnatmake -I../binding $@.adb -largs -L/usr/lib -lblas -llapack FORCE: clean: -rm ${EXECUTABLE} -rm *.ali -rm *.o ---------------------------- The FORCE trick above forces Make to invoke gnatmake each time. That is OK, since gnatmake then decided if it needs to actually compile things or not. In the above example, `-I` just points to other folders that have Ada sources that have packages with'ed by these files. (this is all normal gnatmake stuff here). So, all what one needs to do is make In the above, all output (exeutables and ali files and .o files are generated in the same folder). make clean will clean everything. Now one can add more target to the Makefile to do other things, like run a specific test, etc... i.e. Normal Makefile things. --Nasser